// Copyright 2019 The rhyme_lph Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// I [author] rhyme_lph
// s [email]  rhymelph@gmail.com
// h [github] https://github.com/rhymelph

import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/widgets/button/normal_border_button.dart';
import 'package:finance_app/src/widgets/common_app_bar.dart';
import 'package:finance_app/src/widgets/list_item/sub_billing_item.dart';
import 'package:flutter/material.dart';
import 'package:finance_app/src/provider/setting/subscription/sub_pay_provider.dart';
import 'package:finance_app/src/router_gen/router_meta.dart';

@RouterMeta(paramName: "subPayPage")
class SubPayPage extends StatefulWidget {
  final String paymentMethod;

  const SubPayPage({Key key, this.paymentMethod}) : super(key: key);

  @override
  _SubPayPageState createState() => _SubPayPageState();
}

class _SubPayPageState extends State<SubPayPage>
    with PagePresenter<SubPayPage, SubPayProvider> {
  @override
  PreferredSizeWidget get appBar =>
      getDefaultAppBar(title: widget.paymentMethod);

  @override
  Widget get buildWidget => ColoredBox(
        color: Colors.white,
        child: ListView(
          padding:
              EdgeInsets.symmetric(horizontal: getDp(25), vertical: getDp(30)),
          children: [
            SubBillingItem(
              currency: 'SGD',
              isHistory: false,
              amount: '30.00',
              billDate: DateTime(2021, 5, 30),
              status: S.current.unpaid,
              onTap: () {},
            ),
            AppSpaces.h30,
            Center(
              child: Container(
                width: getDp(234),
                height: getDp(234),
                color: Colors.amber,
              ),
            ),
            AppSpaces.h30,
            _buildStepTip(
                index: 1, content: S.current.save_this_qr_code_to_your_photos),
            AppSpaces.h20,
            _buildStepTip(
                index: 2, content: S.current.upload_to_your_banks_paynow_page),
            AppSpaces.h30,
            Center(
              child: NormalBorderButton(
                isFit: true,
                title: S.current.save_photo,
                onTap: provider.onSavePhoto,
              ),
            )
          ],
        ),
      );

  Widget _buildStepTip({int index, String content}) => Text.rich(TextSpan(
        children: [
          TextSpan(
            text: S.current.step_index_(index),
            style: TextStyle(
              fontWeight: FontWeight.w700,
            ),
          ),
          TextSpan(
            text: content,
          )
        ],
        style: TextStyle(
            color: aceBlackColor,
            fontSize: getSp(16),
            fontWeight: FontWeight.w400,
            height: 22 / 16,
            fontFamily: "DinRoundPro"),
      ));
}
